/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-19 21:25:39
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-19 22:28:29
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/loading.dart';
import 'package:flutter_data_center/controller/alert_controller.dart';
import 'package:get/get.dart';

import 'alert_item.dart';

class AlertList extends StatelessWidget {
  const AlertList({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) => GetBuilder<AlertController>(
        builder: (_controller) => _controller.list.length > 0
            ? ListView.separated(
                physics: BouncingScrollPhysics(),
                itemBuilder: (BuildContext context, int index) => AlertItem(
                  alert: _controller.list[index],
                ),
                separatorBuilder: (BuildContext context, int index) {
                  return Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 20),
                    child: Divider(),
                  );
                },
                itemCount: _controller.list.length,
              )
            : Loading(),
      );
}
